﻿using System;
using System.Collections.Generic;

namespace WindowsFormsApp1
{
    internal class gjpingyi
    {
        // 固定的6组 x, y 值
        private readonly double[,] fixedPoints = new double[,]
        {
            { 0.0000, -10.0000},
            { 0.0000, -6.0000},
            { 0.0000, -2.0000},
            { 0.0000, 2.0000},
            { 0.0000, 6.0000},
            { 0.0000, 10.0000}
        };

        // 旋转和平移的方法
        public Tuple<double, double> RotateAndTranslatePoint(double x, double y, double theta, double deltaX, double deltaY, bool clockwise = false)
        {
            // 将角度转换为弧度
            double thetaRad = Math.PI * theta / 180.0;

            // 根据旋转方向选择旋转矩阵
            double cosTheta = Math.Cos(thetaRad);
            double sinTheta = Math.Sin(thetaRad);

            double newX, newY;

            if (clockwise)
            {
                // 顺时针旋转
                newX = x * cosTheta + y * sinTheta + deltaX;
                newY = y * cosTheta - x * sinTheta + deltaY;
            }
            else
            {
                // 逆时针旋转
                newX = x * cosTheta - y * sinTheta + deltaX;
                newY = y * cosTheta + x * sinTheta + deltaY;
            }

            return Tuple.Create(newX, newY);
        }

        // 批量计算并返回结果
        public List<Tuple<double, double>> RotateAndTranslateFixedPoints(double theta, double deltaX, double deltaY, bool clockwise = false)
        {
            var transformedPoints = new List<Tuple<double, double>>();

            for (int i = 0; i < fixedPoints.GetLength(0); i++)
            {
                double x = fixedPoints[i, 0];
                double y = fixedPoints[i, 1];

                // 旋转并平移每个固定点
                var transformedPoint = RotateAndTranslatePoint(x, y, theta, deltaX, deltaY, clockwise);
                transformedPoints.Add(transformedPoint);
            }

            return transformedPoints;
        }
    }
}